package com.luych.userModule.controller;

import com.luych.common.page.Page;
import com.luych.userModule.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;

@RestController
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("user")
    @PreAuthorize("hasAuthority('getUser')")
    public Page page(Page page, String keywords) throws InvocationTargetException, IllegalAccessException {
        return userService.page(page, keywords);
    }
}
